package com.project.smarthome.base;

import com.project.smarthome.SmartApplication;

import io.reactivex.Scheduler;
import io.reactivex.disposables.CompositeDisposable;
import io.reactivex.disposables.Disposable;


/**
 * Created by L on 2016/5/18.
 */

public class BasePresenter implements UIPresenter {

    private CompositeDisposable mCompositeSubscription;

    protected Scheduler getJobExecutor() {
        return ApplicationPresenter.getsJobExecutor();
    }

    protected Scheduler getUiExecutor() {
        return ApplicationPresenter.getUiExecutor();
    }

    protected void setStatusBarColor(int colorResId) {
        ApplicationPresenter.setStatusBarColor(colorResId);
    }

    //云平台错误码对应的描述
    protected String getCloudErrorDesc(int errorCode) {
        int resId = 0;
        switch (errorCode) {
        }
        return SmartApplication.getContext().getResources().getString(resId);
    }

    protected void addSubscription(Disposable s) {
        if (mCompositeSubscription == null) {
            mCompositeSubscription = new CompositeDisposable();
        }
        mCompositeSubscription.add(s);
    }

    @Override
    public void init() {

    }

    @Override
    public void destroy() {
        if (mCompositeSubscription != null) {
            mCompositeSubscription.clear();
            mCompositeSubscription = null;
        }
    }

    @Override
    protected void finalize() throws Throwable {
        super.finalize();
    }

}
